package com.poorstu.web.studentApply;

import java.sql.Date;
import java.text.SimpleDateFormat;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;


import com.common.base.web.BaseAction;
import com.poorstu.manager.LoadManager;
import com.poorstu.manager.StudentManager;
import com.poorstu.model.LoadMod;
import com.poorstu.model.LoadMoneyMod;
import com.poorstu.model.LoginMod;

public class LoadShowDetilAction extends BaseAction {

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) {
		
		try{
		int loadId=Integer.parseInt(request.getParameter("loadId"));
		int allUserId =(Integer)request.getSession().getAttribute("allUserId");
		StudentManager stuManager=(StudentManager)getBean("studentManager");
		LoginMod login=stuManager.selectStudentById(allUserId);
		request.setAttribute("login", login);
		
		 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		String birthday= sdf.format(login.getStu().getAges());
		
		request.setAttribute("birthday", birthday);
		
		LoadManager loadManager=(LoadManager)getBean("loadManager");
	
		List<LoadMoneyMod> loadMoney= loadManager.selectLoadMoneyAll();
		request.setAttribute("loadMoney", loadMoney);
		
		LoadMod load=stuManager.selectLoad(loadId);
		request.setAttribute("load", load);
		
		
		return mapping.findForward("succ");
		}
		catch(Exception e){
			e.printStackTrace();
			return mapping.findForward("failure");
		}
	}
	
	

}
